#include "IDHelloWorld.h"

#include <QDBusConnection>
#include <QDBusInterface>
#include <QDBusReply>

#include <LogUtils>

IDHelloWorld::IDHelloWorld(QObject *parent) : QObject(parent)
{
//    QDBusInterface *interface = new QDBusInterface(
//            "com.qt.examples.DHelloWorld", "/", "com.qt.examples.DHelloWorld",
//            QDBusConnection::sessionBus(), this);
//    connect(interface, SIGNAL(broadcastMessage(QString)), this, SLOT(onBroadcastMessage));

    QDBusConnection::sessionBus().connect(
        "com.qt.examples.DHelloWorld",  "/", "com.qt.examples.DHelloWorld",  "broadcastMessage",
        this, SLOT(slotBroadcastMessage(QString)));
}


void IDHelloWorld::slotBroadcastMessage(QString msg)
{
    LogUtils::log("LogUtils: " + msg);
    emit broadcastMessage(msg);
}
